package com.vision.sales.cl.ui;

import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
import com.vision.core.cm.db.data.Company;
import com.vision.sales.cm.db.data.Customer;
import com.vision.sales.cm.db.data.Salesman;

public class SalesUI {
	
	public static AbstractCell<Customer> customerCodeCell() {
		return new AbstractCell<Customer>() {
			@Override
			public void render(Context context, Customer customer, SafeHtmlBuilder sb) {
				sb.append(SafeHtmlUtils.fromTrustedString(customer.getCode()));
			}
		};
	}
	
	@Deprecated
	public static AbstractCell<Customer> customerNameCell() {
		return new AbstractCell<Customer>() {
			@Override
			public void render(Context context, Customer customer, SafeHtmlBuilder sb) {
				sb.append(SafeHtmlUtils.fromTrustedString(customer.getName()));
			}
		};
	}
	
	
	public static AbstractCell<Company> companyCodeCell() {
		return new AbstractCell<Company>() {
			@Override
			public void render(Context context, Company company, SafeHtmlBuilder sb) {
				sb.append(SafeHtmlUtils.fromTrustedString(company.getCode()));
			}
		};
	}
	
	public static AbstractCell<Company> companyNameCell() {
		return new AbstractCell<Company>() {
			@Override
			public void render(Context context, Company company, SafeHtmlBuilder sb) {
				sb.append(SafeHtmlUtils.fromTrustedString(company.getName()));
			}
		};
	}
	
	public static AbstractCell<Salesman> salesmanCodeCell() {
		return new AbstractCell<Salesman>() {
			@Override
			public void render(Context context, Salesman salesman, SafeHtmlBuilder sb) {
				sb.append(SafeHtmlUtils.fromTrustedString(salesman.getCode()));
			}
		};
	}
	
	public static AbstractCell<Salesman> salesmanNameCell() {
		return new AbstractCell<Salesman>() {
			@Override
			public void render(Context context, Salesman salesman, SafeHtmlBuilder sb) {
				sb.append(SafeHtmlUtils.fromTrustedString(salesman.getName()));
			}
		};
	}
	
}
